#import "../poker.h"

@implementation Preferences

+ (id)sharedInstance {
   static id shared = nil;

   if (!shared) {
       shared = [[self allocWithZone:NULL] init];
   }
   return shared;
}

- (id)init {
   self = [self initWithWindowNibName:NSStringFromClass([self class])];
   if (self) {
       [self setWindowFrameAutosaveName:NSStringFromClass([self class])];
   }
   return self;
}


- (IBAction)changeUserNameAction:(id)sender {
    NSString *user = [sender stringValue];
    if (![user isEqualToString:@""] && user)
    [[NSUserDefaults standardUserDefaults] setObject:user forKey:@"Name"];
}

- (void)showWindow:(id)sender {
   [super showWindow:sender];
    [userNameField setStringValue:[[NSUserDefaults standardUserDefaults] objectForKey:@"Name"]];
}
@end
